package com.zwz.service.impl;

import com.zwz.entity.EnterpriseAnnualReport;
import com.zwz.entity.EnterpriseInfo;
import com.zwz.mapper.EnterpriseAnnualReportMapper;
import com.zwz.service.EnterpriseAnnualReportService;
import com.zwz.voObject.AnnulReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
@Transactional
public class EnterpriseAnnualReportServiceImpl implements EnterpriseAnnualReportService {

    @Autowired
    private EnterpriseAnnualReportMapper mapper;

    @Override
    public void create(EnterpriseAnnualReport report) {
        //
        // 主表操作
        // 创建主表记录
        EnterpriseInfo enterpriseInfo=new EnterpriseInfo();
        enterpriseInfo.setId(Long.valueOf(report.getEnterpriseId()));

        //最后关联上
        report.setEnterpriseId(Math.toIntExact(enterpriseInfo.getId()));

        mapper.insert(report);
    }

    @Override
    public EnterpriseAnnualReport getById(Integer id) {
        return mapper.selectById(id);
    }

    @Override
    public void update(EnterpriseAnnualReport report) {
        mapper.update(report);
    }

    @Override
    public void deleteById(Integer id) {
        mapper.deleteById(id);
    }

    @Override
    public List<EnterpriseAnnualReport> getAll() {
        return mapper.selectAll();
    }

    @Override
    public List<EnterpriseAnnualReport> getByYear(Integer year) {
        return mapper.selectByYear(year);
    }

    @Override
    public List<AnnulReport> getAnnulReportInfo(String  id) {
        return mapper.getAnnulReportInfo(id);
    }
}